package com.zj.weather.base;

import android.content.Context;
import android.graphics.Canvas;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaojie on 2018/7/23.
 */

public abstract class HoldersInfo {

    public HoldersInfo(int maxCount) {
        if (holders == null) {
            holders = new ArrayList<>();
        } else {
            holders.clear();
        }
        for (int i = 0; i < maxCount; i++) {
            holders.add(getHolderType(i));
        }
    }

    public List<BaseHolder> holders;

    public abstract BaseHolder getHolderType(int position);

    public void upDateHoldersValue(Context context, Canvas canvas, float changedAlpha) {
        if (holders == null) return;
        for (BaseHolder holder : holders) {
            holder.updateFrame(context, canvas, changedAlpha);
        }
    }

    public void initHolders(Context context) {
        if (holders == null) return;
        for (BaseHolder holder : holders) {
            holder.initData(context);
        }
    }
}
